class Person {
  constructor (name, age) {
    this._name = name  //属性
    this._age = age
  }
  getName () {  //实例方法
    console.log(this._name)
  }
  setName (name) {
    this._name = name
  }
  static work () {  //静态方法
    console.log('这是es6里面的静态方法')
  }
}

let p = new Person('张三', 20)

p.getName()
p.setName('李四', 40)
p.getName()

Person.work()


class Web extends Person { //Web 继承了 person
  constructor (name, age, sex) {
    super(name, age) //实例化子类的时候把子类的数据传个父类
    this.sex = sex
  }
  print () {
    console.log(`${this._name}-${this._age}-${this.sex}`)
  }
}

let w = new Web('王五', 30, '男')

w.print()